package 面向对象初级.方法.再谈方法;

public class Method05 {
   //求n个整数的和
    public int add(int[] nums,int a){
        int count=0;
        for (int i = 0; i < nums.length; i++) {
            count+=nums[i];
        }
        return count;
    }

    //换一种写法
    public int add(int...nums){
        int count=0;
        for (int i = 0; i < nums.length; i++) {
            count+=nums[i];
        }
        return count;
    }

    public static void main(String[] args) {
        Method05 method05 = new Method05();
        int[] arr={13,14,43};
        System.out.println(method05.add(arr));

        System.out.println(method05.add());
        System.out.println(method05.add(56));
        System.out.println(method05.add(7,8));
        System.out.println(method05.add(1,2,3,4,5,6,7,8,9));
    }
}
